package com.app.micaihu.view.army.adapter

import android.widget.ImageView
import android.widget.TextView
import com.app.micaihu.R
import com.app.micaihu.configure.Config
import com.app.micaihu.utils.StatServiceUtils
import com.app.micaihu.view.bean.ArmyList
import com.app.micaihu.view.utils.loadImage
import com.blankj.utilcode.util.CollectionUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * 未加入军团列表适配器
 */
class NoJoinedArmyListAdapter : BaseQuickAdapter<ArmyList.ArmyGroup, BaseViewHolder>(R.layout.army_join_no_list_item), LoadMoreModule {

    override fun convert(holder: BaseViewHolder, item: ArmyList.ArmyGroup) {
        StatServiceUtils.event(Config.EventBauduId.teamlistapply_exposure, "军团_申请列表曝光")
        holder.apply {
            getView<ImageView>(R.id.ivArmyIcon).loadImage(item.icon)
            setText(R.id.tvArmyTitle, item.title)
            setText(R.id.tvDescription, item.description)
            setText(R.id.tvMember, item.member + "/" + item.memberLimit)
            setText(R.id.tvGid, "番号 " + item.gid)
            setText(R.id.tvWarZone, item.warZone)
            setText(R.id.tvLevel, item.level)
            getView<TextView>(R.id.tvMember).setCompoundDrawablesWithIntrinsicBounds(R.mipmap.army_member_icon, 0, 0, 0)
            val tag = item.tag
            if (tag.isNullOrEmpty()) {
                setGone(R.id.llArmyTag, true)
            } else {
                setVisible(R.id.llArmyTag, true)
                when (tag.size) {
                    1 -> {
                        setVisible(R.id.tvArmyTag1, true)
                        setText(R.id.tvArmyTag1, tag[0])
                        ///////////////////////////////////////////////
                        setGone(R.id.viewArmyTag1, true)
                        setGone(R.id.tvArmyTag2, true)
                        setGone(R.id.viewArmyTag2, true)
                        setGone(R.id.tvArmyTag3, true)
                    }
                    2 -> {
                        setVisible(R.id.tvArmyTag1, true)
                        setText(R.id.tvArmyTag1, tag[0])
                        ///////////////////////////////////////////////
                        setVisible(R.id.viewArmyTag1, true)
                        setVisible(R.id.tvArmyTag2, true)
                        setText(R.id.tvArmyTag2, tag[1])
                        ///////////////////////////////////////////////
                        setGone(R.id.viewArmyTag2, true)
                        setGone(R.id.tvArmyTag3, true)

                    }
                    3 -> {
                        setVisible(R.id.tvArmyTag1, true)
                        setText(R.id.tvArmyTag1, tag[0])

                        setVisible(R.id.viewArmyTag1, true)
                        setVisible(R.id.tvArmyTag2, true)
                        setText(R.id.tvArmyTag2, tag[1])

                        setVisible(R.id.viewArmyTag2, true)
                        setVisible(R.id.tvArmyTag3, true)
                        setText(R.id.tvArmyTag3, tag[2])
                    }
                }
            }
        }


    }
}